package com.haddonhillgroup.sample.rest;

import org.beaconframework.util.DomUtil;
import org.w3c.dom.Document;

import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.config.DefaultClientConfig;

public class GoogleCodeIssueClient {

	private WebResource getRoot() {
		DefaultClientConfig cc = new DefaultClientConfig();

		com.sun.jersey.api.client.Client c = com.sun.jersey.api.client.Client
				.create(cc);
		return c.resource("http://code.google.com/feeds/issues");
	}

	// WebResource wr =
	// c.resource("http://search.twitter.com/search.atom").queryParam("q",
	// "lebowski");

	public void printAll(String project) {
		DomUtil.prettyPrint(System.out, (Document) getRoot().path("p").path(
				project).path("issues/full").get(Document.class));
	}

	public void printIssue(String project, int issue) {
		DomUtil.prettyPrint(System.out, (Document) getRoot().path("p").path(
				project).path("issues").path("" + issue).path("comments/full")
				.get(Document.class));

	}
}
